/*
 * Copyright (c) 2009 Johnny Mast
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>


#if !defined(GAMENGINE_DEBUG)
#define GAMENGINE_DEBUG 1
#endif

#pragma mark -
#pragma mark Special structures or macro's
#import "Common/CommonElements.h"

#pragma mark -
#pragma mark Special Engine objects
#import "Math/Vector2D.h"
#import "Math/Vector3D.h"
#import "Math/Circular.h"

#pragma mark -
#pragma mark Abstracts
#import "Abstracts/GameScene.h"

#pragma mark -
#pragma mark helpers
#import "DDXML/DDXML.h"
#import "Protocols/GameEngineDelegate.h"
#import "Protocols/GameSceneDelegate.h"
#import "Protocols/GameCharacterDelegate.h"
#import "AccelerometerSim/AccelerometerSimulation.h"
#import "Helpers/Sound/SoundHelpers.h"

#pragma mark -
#pragma mark Managers
#import "Managers/Resources.h"
#import "Managers/Scenes.h"
#import "Managers/Sound.h"

#pragma mark -
#pragma mark 2D Engine includes
#import "2D/Texture/Texture2D.h"
#import "2D/Particles/ParticleEmitter.h"
#import "2D/BitmapFonts/HieroBitmapFont.h"
#import "2D/SpriteSheet/SpriteSheet.h"
#import "2D/Animation/Animation.h"
#import "2D/TileMap/TileMap.h"
#import "2D/Images/Image.h"
#import "2D/Blink/Blink.h"

#define PORTRATE_MODE NO
#define USE_DEPTH_BUFFER NO
#define kAccelerometerFilteringFactor 0.05//0.05
#define kAccelerometerUpdateFrequency 100 // Hz

@interface GameEngine : UIView <UIAlertViewDelegate> {
	id <GameEngineDelegate> delegate;
	CGRect screenBounds;
	
	CFTimeInterval lasttime;
	NSTimeInterval framerate;
	NSTimer *gametimer;	

	/* The pixel dimensions of the backbuffer */
    GLint backingWidth;
    GLint backingHeight;
    
    EAGLContext *context;
    
	XFFloat _XFfps;
	
    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
    GLuint viewRenderbuffer, viewFramebuffer;
    
    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
    GLuint depthRenderbuffer;
}
@property(nonatomic, retain) id <GameEngineDelegate> delegate;
@property(nonatomic) CGRect screenBounds;
@property(nonatomic) GLint backingWidth;
@property(nonatomic) GLint backingHeight;
@property(nonatomic) GLuint viewRenderbuffer;
@property(nonatomic) GLuint viewFramebuffer;
@property(nonatomic) GLuint depthRenderbuffer;
@property(nonatomic, retain) EAGLContext *context;
@property(nonatomic, retain) NSTimer* gametimer;
@property CFTimeInterval lasttime;
@property NSTimeInterval framerate;
@property  XFFloat _XFfps;

-(void)setDelegate:(id<GameEngineDelegate>)gamedelegate;
-(void)MainGameLoop;
@end